package com.chen.config; /**
 * @ProjectName: springBootXm
 * @Package: com.chen.bolg.Config
 * @ClassName: MybatisPlusConfig
 * @Author: Chen
 * @Description: MybatisPlus配置类
 * @Date: 2022/7/28 14:10
 * @Version: 1.0
 */

import com.baomidou.mybatisplus.annotation.DbType;
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @ClassNameMybatisPlusConfig
 * @Author CWS
 * @Date 2022/7/28 14:10
 * @Version 1.0
 **/


@Configuration
public class MybatisPlusConfig {

    @Bean
    public MybatisPlusInterceptor mybatisPlusInterceptor(){
        //        1.定义map拦截器
        MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
//        2.添加具体的拦截器
        PaginationInnerInterceptor paginationInnerInterceptor = new PaginationInnerInterceptor();
        paginationInnerInterceptor.setDbType(DbType.MYSQL);
        paginationInnerInterceptor.setOverflow(true);//解决页码溢出
        interceptor.addInnerInterceptor(paginationInnerInterceptor);
        return interceptor;
    }
}
